package org.s170.servlet.HouTaiServlet;

import org.s170.dao.AdmintratoDao;
import org.s170.entity.Admintrao;
import org.s170.servlet.BaseServlet;
import org.s170.utils.JwtUtil;


import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
@WebServlet("/admin/adminAll")
public class AdminListServlet extends BaseServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // 获取客户端发送过来的token
        // String token = req.getParameter("token");
        String token = req.getHeader("Authorization");

        // 获取payload信息
        String username = JwtUtil.getPayload(token, "username", String.class);
        AdmintratoDao dao=new AdmintratoDao();
        List<Admintrao> list=dao.queryAll();
        print(resp, successJson(list));
    }
}
